package com.csdn.service.impl;

import com.csdn.dao.UserMapper;
import com.csdn.entity.User;
import com.csdn.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public User getUser(Long id, String name) {
        if (id == null) {
            throw new RuntimeException("ID 不能为空");
        }
        if(StringUtils.isEmpty(name)){
            throw new RuntimeException("名称不能为空");
        }
        User user = userMapper.getById(id);
        return user;
    }
}
